package br.com.sitran.bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name="cliente")
public class Cliente implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="id_cliente",nullable=false)
	private Integer id;
	@Column(name="nome",nullable=false)
	private String nome;
	@Column(name="endereco",nullable=false)
	private String endereco;
	@Column(name="cnpj",nullable=false)
	private String cnpj;
	@Column(name="cep",nullable=false)
	private String cep;
	@OneToMany(mappedBy="cliente",fetch=FetchType.LAZY,cascade=CascadeType.ALL)
	private List<Encomenda> listaEncomendas;
//	@OneToOne(mappedBy="cliente",cascade=CascadeType.ALL)
//	private Login login;
	
	
	public Cliente() {
		
	}
	
	
	
	public Cliente(Integer id) {
		
		this.id = id;
	}
	
	


	public Cliente(Integer id, String nome, String endereco, String cnpj,
			String cep, List<Encomenda> listaEncomentas) {
		this.id = id;
		this.nome = nome;
		this.endereco = endereco;
		this.cnpj = cnpj;
		this.cep = cep;
		this.listaEncomendas = listaEncomendas;
		//this.login = login;
	}



	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getEndereco() {
		return endereco;
	}
	public void setEndereco(String endereco) {
		this.endereco = endereco;
	}
	public String getCnpj() {
		return cnpj;
	}
	public void setCnpj(String cnpj) {
		this.cnpj = cnpj;
	}
	public String getCep() {
		return cep;
	}
	public void setCep(String cep) {
		this.cep = cep;
	}

	public List<Encomenda> getListaEncomendas() {
		return listaEncomendas;
	}



	public void setListaEncomentas(List<Encomenda> listaEncomendas) {
		this.listaEncomendas = listaEncomendas;
	}

	

//	public Login getLogin() {
//		return login;
//	}
//
//
//
//	public void setLogin(Login login) {
//		this.login = login;
//	}



	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Cliente other = (Cliente) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	
	
	
	
	
}
